package Modelo;

import com.puj.bdutils.ConnectorBD;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class TransaccionSql
{
  public static ResultSet ejecutarConsulta(String consulta)
    throws SQLException
  {
    Connection conn = ConnectorBD.getConnection(Path.ruta);
    ResultSet rs = ejecutarConsulta(consulta, conn);
    conn.close();
    return rs;
  }

  public static int insertar(String consulta)
    throws SQLException
  {
    Connection conn = ConnectorBD.getConnection(Path.ruta);
    int result = insertar(consulta, conn);
    conn.close();
    return result;
  }

  public static int actualizar(String consulta)
    throws SQLException
  {
    Connection conn = ConnectorBD.getConnection(Path.ruta);
    int result = actualizar(consulta, conn);
    conn.close();
    return result;
  }

  public static ResultSet ejecutarConsulta(String consulta, Connection conn)
    throws SQLException
  {
    Statement sttmnt = conn.createStatement();
    return sttmnt.executeQuery(consulta);
  }

  public static int insertar(String consulta, Connection conn)
    throws SQLException
  {
    Statement sttmnt = conn.createStatement();
    return sttmnt.executeUpdate(consulta);
  }

  public static int actualizar(String consulta, Connection conn)
    throws SQLException
  {
    Statement sttmnt = conn.createStatement();
    return sttmnt.executeUpdate(consulta);
  }
}